<template>
	<view class="cleanstaff">
		<view class="bag_box">
			<u-image src="/static/image/bannerzm.png" width="100%" height="421rpx"></u-image>
		</view>
		<view class="main-box">
			<!-- 上 -->
			<view class="pos-box">
				<view class="box-top">
					<view class="title">个人信息</view>
					<!-- 表单 -->
					<u-form :model="cleanerForm" ref="cleanerRef" label-width="120rpx"
						:label-style="{fontWeight:'700'}">
						<u-form-item label="姓名" :border-bottom="false">
							<view class="input-box">
								<!-- 输入框 -->
								<view class="input">
									<u-input v-model="cleanerForm.name" placeholder="请填写姓名" :clearable="false"
										maxlength="10" />
								</view>
								<!-- 单选 -->
								<view class="radio-box">
									<u-radio-group v-model="cleanerForm.gender">
										<u-radio v-for="(item, index) in radioList" :key="index" :name="item.name"
											label-size="22rpx" active-color="#01C3A8">
											{{ item.name == 0 ? '女士' : '先生' }}
										</u-radio>
									</u-radio-group>
								</view>
							</view>
						</u-form-item>

						<u-form-item label="手机号" :border-bottom="false">
							<view class="inputtwo-box">
								<u-input v-model="cleanerForm.tel" placeholder="请填写手机号码" :clearable="false"
									maxlength="11" />
								<strong></strong>
							</view>
						</u-form-item>

						<u-form-item label="城市" :border-bottom="false">
							<view class="inputtwo-box">
								<u-input v-model="cleanerForm.home_city" placeholder="请输入城市" :clearable="false"
									maxlength="11" />
							</view>
						</u-form-item>

					</u-form>
				</view>
			</view>
			<!-- 分割 -->
			<view class="middle"></view>
			<!-- 下 -->
			<view class="box-bom">
				<view class="title">我的技能</view>
				<view class="bom-tag">
					<block v-for="(item,i) in SkillList" :key="i">
						<view :class="['tags', {'tagtacive':i === tagindex}] " @click="dotags(i,item)">{{item}}</view>
					</block>

				</view>

			</view>
		</view>
		<!-- 底部 -->
		<view class="footer">
			<button class="btn" @click="Toinfo">提交信息</button>
		</view>
	</view>
</template>

<script>
	import { ResSkill } from '@/untils/api.js'
	export default {
		data() {
			return {
				cleanerForm: {
					name: '',
					gender: '1',
					tel: '',
					home_city: '',
					type: '',
				},
				radioList: [
					{ name: 1 },
					{ name: 0 }
				],
				SkillList: [],
				tagindex: 0

			}
		},
		onLoad() {
			this.getSkill()

		},
		methods: {
			Toinfo() {
				// 进行校验
				if (!this.cleanerForm.name) return uni.$showMsg('请输入姓名')
				if (!this.cleanerForm.tel) return uni.$showMsg('请输入手机号')
				if (!this.cleanerForm.home_city) return uni.$showMsg('请输入城市')
				let reg = /^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/
				if (!reg.test(this.cleanerForm.tel)) return uni.$showMsg('请输入正确的11位手机号码')
				// 页面跳转并清空表单
				uni.navigateTo({
					url: `/pages/Cleaner/CleanerInfo?data=${JSON.stringify(this.cleanerForm)}`
				})
				this.cleanerForm.name = ''
				this.cleanerForm.tel = ''
				this.cleanerForm.home_city = ''
			},
			dotags(i, item) {
				console.log(item);
				this.tagindex = i
				this.cleanerForm.type = item
			},
			async getSkill() {
				const { data: res } = await ResSkill()
				this.SkillList = res.data
				// 初次默认拿到第一项的值
				this.cleanerForm.type = res.data[0]
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cleanstaff {
		padding-bottom: 128rpx;


		.main-box {
			padding: 0 24rpx 136rpx;
			background-color: #F7F7F7;

			// 公共样式
			.title {
				font-size: 34rpx;
				font-weight: 700;

			}

			.box-bom,
			.box-top {
				background-color: #fff;
				padding: 42rpx 20rpx;
				border-radius: 24rpx;
			}

			// 上
			.pos-box {
				position: relative;
				height: 430rpx;

				.box-top {
					width: 100%;
					padding-bottom: 30rpx;
					position: absolute;
					top: -24rpx;
					left: 0;
					z-index: 1;


					.input-box {
						display: flex;
						justify-content: space-between;
						align-items: center;
						border-bottom: 1px solid #F0EDED;
					}

					.inputtwo-box {
						border-bottom: 1px solid #F0EDED;
					}


				}
			}

			// 中
			.middle {
				height: 15rpx;
			}

			// 下
			.box-bom {


				.bom-tag {
					display: flex;
					flex-wrap: wrap;

					.tagtacive {
						background-color: #F0FFFC !important;
						color: #01C3A8;
					}

					.tags {
						height: 62rpx;
						padding: 0 10rpx;
						background-color: #F7F7F7;
						text-align: center;
						line-height: 62rpx;
						margin: 30rpx 30rpx 0 0;
					}
				}
			}

		}

		// 底部
		.footer {
			width: 100%;
			height: 128rpx;
			background-color: #fff;
			padding: 20rpx 0;
			position: fixed;
			bottom: 0;
			left: 0;

			.btn {
				width: 676rpx;
				height: 84rpx;
				line-height: 84rpx;
				background-color: #01C3A8;
				color: #F3FFFE;
				font-size: 30rpx;
				border-radius: 42rpx;
			}

			button.btn::after {
				border: none;
			}
		}
	}
</style>
